package modules.lobby.view
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.MouseEvent;
	
	import modules.GameDispatcher;
	import modules.lobby.LobbyEvent;

	/**
	 * @author lee
	 */
	public class BalanceView
	{
		private var mainUI:MovieClip;
		private var dispatcher:EventDispatcher;
		
		public function BalanceView(mainUI:MovieClip)
		{
			this.mainUI = mainUI;	
			dispatcher = GameDispatcher.instance;
			init();
		}
		
		
		private function init():void
		{
			dispatcher.addEventListener(LobbyEvent.SHOW_UI_BALANCE,showUI);
			mainUI.realMoneyAvailableMc.checkBoxMc.mouseChildren = false;
			mainUI.realMoneyAvailableMc.lable.mouseEnabled = false;
			mainUI.realMoneyAvailableMc.checkBoxMc.buttonMode = true;
			mainUI.realMoneyInPlayMc.checkBoxMc.mouseChildren = false;
			mainUI.realMoneyInPlayMc.lable.mouseEnabled = false;
			mainUI.realMoneyInPlayMc.checkBoxMc.buttonMode = true;
			mainUI.realMoneyTotalMc.checkBoxMc.mouseChildren = false;
			mainUI.realMoneyTotalMc.lable.mouseEnabled = false;
			mainUI.realMoneyTotalMc.checkBoxMc.buttonMode = true;
			mainUI.myTicketsMc.checkBoxMc.mouseChildren = false;
			mainUI.myTicketsMc.lable.mouseEnabled = false;
			mainUI.myTicketsMc.checkBoxMc.buttonMode = true;
			mainUI.playMoneyAvailableMc.checkBoxMc.mouseChildren = false;
			mainUI.playMoneyAvailableMc.lable.mouseEnabled = false;
			mainUI.playMoneyAvailableMc.checkBoxMc.buttonMode = true;
			mainUI.playMoneyInPlayMc.checkBoxMc.mouseChildren = false;
			mainUI.playMoneyInPlayMc.lable.mouseEnabled = false;
			mainUI.playMoneyInPlayMc.checkBoxMc.buttonMode = true;
			mainUI.playMoneyTotalMc.checkBoxMc.mouseChildren = false;
			mainUI.playMoneyTotalMc.lable.mouseEnabled = false;
			mainUI.playMoneyTotalMc.checkBoxMc.buttonMode = true;
			
			mainUI.realMoneyAvailableMc.checkBoxMc.checkBoxTxt.text = "Available";
			mainUI.realMoneyInPlayMc.checkBoxMc.checkBoxTxt.text = "In Play";
			mainUI.realMoneyTotalMc.checkBoxMc.checkBoxTxt.text = "Total";
			mainUI.myTicketsMc.checkBoxMc.checkBoxTxt.text = "Tickets";
			mainUI.playMoneyAvailableMc.checkBoxMc.checkBoxTxt.text = "Available";
			mainUI.playMoneyInPlayMc.checkBoxMc.checkBoxTxt.text = "In Play";
			mainUI.playMoneyTotalMc.checkBoxMc.checkBoxTxt.text = "Total";
		}
			
		private function addEventListeners():void
		{
			mainUI.refreshBtn.addEventListener(MouseEvent.CLICK,refreshUI);
			mainUI.closeBtn.addEventListener(MouseEvent.CLICK,closeUI);
		}
		
		private function removeEventListeners():void
		{
			mainUI.refreshBtn.removeEventListener(MouseEvent.CLICK,refreshUI);
			mainUI.closeBtn.removeEventListener(MouseEvent.CLICK,closeUI);
		}
		
		private function showUI(e:LobbyEvent):void
		{
			addEventListeners();
			mainUI.x = (UIAllRefer.stage.stageWidth - mainUI.width) >> 1;
			mainUI.y = (UIAllRefer.stage.stageHeight - mainUI.height) >> 1;
			UIAllRefer.popLayer.addChild(mainUI);
		}
		
		private function closeUI(e:Event):void
		{
			if(mainUI.parent)
			{
				removeEventListeners();
				UIAllRefer.popLayer.removeChild(mainUI);
			}
		}
		
		private function refreshUI(e:Event):void
		{
		}
		
	}
}